package com.chuangke.lowcode.component.handle;

import com.chuangke.common.constant.ColumnConstants;
import com.chuangke.context.service.ContextService;
import com.chuangke.lowcode.LowCodeContext;
import com.chuangke.lowcode.component.ProgressComponent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * QueryWrapper组织组件
 * 数据权限过滤
 */
@Component
public class BeforeActionHandlerDeptDataAuthComponent implements ProgressComponent {

    @Autowired
    private ContextService contextService ;

    @Override
    public void process(LowCodeContext modelContext) {
        List<String> deptIds = contextService.findUserDataDeptIdDetailData() ;
        modelContext.getQueryWrapper().in(ColumnConstants.COL_DEPT_ID, deptIds) ;
    }

}
